package com.itheima.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class redisController {
    @Autowired
    private RedisTemplate redisTemplate;

    @GetMapping("/get/{key}")
    public Object get( @PathVariable("key") String key ) {
//        redisTemplate.boundValueOps("na").set("me");
        Object na = redisTemplate.boundValueOps(key).get();
        return na;
    }


    @GetMapping("/set/{key}/{value}")
    public Object set(@PathVariable("key") String key,
                      @PathVariable("value") String value){
        redisTemplate.boundValueOps(key).set(value);
        return "set over";
    }


}
